import { uniqueId } from 'lodash'

/**
 * @description 给菜单数据补充上 path 字段
 * @description https://github.com/d2-projects/d2-admin/issues/209
 * @param {Array} menu 原始的菜单数据
 */
function supplementPath (menu) {
  return menu.map(e => ({
    ...e,
    path: e.path || uniqueId('d2-menu-empty-'),
    ...e.children ? {
      children: supplementPath(e.children)
    } : {}
  }))
}

export const menuHeader = supplementPath([
  { path: '/screen', title: '大屏', icon: 'bookmark-o' },
])

export const menuAside = supplementPath([
  { path: '/index', title: '首页', icon: 'home' },
  {
    title: '租户管理',
    icon: 'users',
    children: [
      { path: '/tenant/account-management', title: '开户管理' },
      { path: '/tenant/tenant-monitor', title: '租户监控' },
    ]
  },
  {
    title: '财务管理',
    icon: 'credit-card',
    children: [
      { path: '/finance/charge-billing', title: '充值缴费' },
      { path: '/finance/financial-reconciliation', title: '财务对账' },
      { path: '/finance/charge-record', title: '充值记录' },
      { path: '/finance/account-settlement', title: '销户结算' },
    ]
  },
  {
    title: '设备管理',
    icon: 'cogs',
    children: [
      { path: '/device/electric-meter', title: '电表管理' },
      { path: '/device/water-meter', title: '水表管理' },
    ]
  },
  {
    title: '系统管理',
    icon: 'cog',
    children: [
      { path: '/system/operation-record', title: '操作记录' },
      { path: '/system/charging-scheme', title: '收费方案' },
      { path: '/system/timing-scheme', title: '定时方案' },
    ]
  },
  {
    title: '报表管理',
    icon: 'bar-chart',
    children: [
      { path: '/report/device-report', title: '设备报表' },
    ]
  }
])

